package me.haoliang.akkaDemo

import akka.actor.{ActorSystem, Props}
import akka.dispatch.ExecutionContexts._
import akka.pattern.ask
import akka.util.Timeout

import scala.concurrent.duration._

/**
  * author: planck 
  * createTime: 2016/11/3.
  */
object Sample {
  implicit val ec = global
  val fun: PartialFunction[Any, Unit] = (result: Any) => {
    result match {
      case x => println(x)
    }
  }

  def main(args: Array[String]): Unit = {
    val filePath ="d://text.txt"
    val system = ActorSystem("system")
    val actor = system.actorOf(Props(new WordCounterActor(filePath)))
    implicit val timeOut = Timeout(25 seconds)
    val future = actor ? StartProcessFileMsg()
    //future.onSuccess(fun)

    future.onSuccess {
      case result => {
        println(result)
        system.terminate()
      }
    }

  }
}
